/**
 * HardwareType.java 16.07.2007
 */
package org.dicr.util.rfc;

/**
 * Hardware Type (hrd)<BR>
 * RFC Assigned Numbers
 * 
 * @author <A href='http://dicr.org'>Igor A Tarasov</A>
 * @version 070716
 */
public enum HardwareType {
	/** Ethernet (10Mb) */
	Ethernet(1),

	/** Experimental Ethernet (3Mb) */
	Experimental(2),

	/** Amateur Radio AX.25 */
	Amateur(3),

	/** Proteon ProNET Token Ring */
	ProNet(4),

	/** Chaos */
	Chaos(5),

	/** IEEE 802 Networks */
	IEEE802(6),

	/** ARCNET */
	ARCNET(7),

	/** Hyperchannel */
	Hyperchannel(8),

	/** Lanstar */
	Lanstar(9),

	/** Autonet Short Address */
	Autonet(10),

	/** LocalTalk */
	LocalTalk(11),

	/** LocalNet (IBM PCNet or SYTEK LocalNET) */
	LocalNet(12),

	/** Ultra link */
	UltraLink(13),

	/** SMDS */
	SMDS(14),

	/** Frame Relay */
	FrameRelay(15),

	/** Asynchronous Transmission Mode (ATM) */
	ATM(16),

	/** HDLC */
	HDLC(17),

	/** Fibre Channel */
	FibreChannel(18),

	/** Asynchronous Transmission Mode (ATM) */
	ATM2(19),

	/** Serial Line */
	SerialLine(20),

	/** Asynchronous Transmission Mode (ATM) */
	ATM3(21),

	/** MIL-STD-188-220 */
	MIL_STD(22),

	/** Metricom */
	Metricom(23),

	/** IEEE 1394.1995 */
	IEE1394(24),

	/** MAPOS */
	MAPOS(25),

	/** Twinaxial */
	Twinaxial(26),

	/** EUI-64 */
	EUI64(27),

	/** HIPARP */
	HIPARP(28),

	/** IP and ARP over ISO 7816-3 */
	IP_ARP(29),

	/** ARPSec */
	ARPSec(30),

	/** IPsec tunnel */
	IPsec(31),

	/** InfiniBand (TM) */
	InfiniBand(32),

	/** TIA-102 Project 25 Common Air Interface (CAI) */
	TIA102(33);

	private int code = 0;

	/** Constructor */
	private HardwareType(final int aCode) {
		this.code = aCode;
	}

	/**
	 * Return code
	 * 
	 * @return type code
	 */
	public int getCode() {
		return this.code;
	}

	/**
	 * Return Hardware Type by code
	 * 
	 * @param code type code
	 * @return Hardware Type or null if code unknown
	 */
	public static HardwareType byCode(final int code) {
		final HardwareType[] types = HardwareType.values();
		for (final HardwareType type : types) {
			if (type.getCode() == code) return type;
		}
		return null;
	}
}
